using System.Collections;
using System.Collections.Generic;
using DanMuHelper.Tools;
using TMPro;
using UnityEngine;

namespace PickMeUp
{
    public class GlobalLoadingPanel : MonoBehaviourSingleton<GlobalLoadingPanel>
    {
        public TMP_Text loadingText;

        public void InitGlobalLoadingPanel()
        {
            var prefab = Resources.Load<GlobalLoadingPanel>("Prefabs/UI/GlobalLoadingPanel");
            var instance = Instantiate(prefab);
            instance.name = "[GlobalLoadingPanel]";
            DontDestroyOnLoad(instance.gameObject);
        }

        public void ShowGlobalLoadingPanel(string tipContent)
        {
            if (string.IsNullOrEmpty(tipContent))
            {
                loadingText.text = "Loading...";
            }
            else loadingText.text = tipContent;
            gameObject.SetActive(true);
        }

        public void HideGlobalLoadingPanel()
        {
            gameObject.SetActive(false);
        }
    }
}
